/*
 * Cs1555PrjApp.java
 */
package cs1555prj;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class Cs1555PrjApp extends SingleFrameApplication {

    private MyDataBase db = new MyDataBase();

    /**
     * At startup create and show the main frame of the application.
     */
    @Override
    protected void startup() {
        show(new Cs1555PrjView(this, db));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override
    protected void configureWindow(java.awt.Window root) {
        root.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                db.closeConnection();
                System.out.println("Window Closing, Database closing!\n");
            }
        });

    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of Cs1555PrjApp
     */
    public static Cs1555PrjApp getApplication() {
        return Application.getInstance(Cs1555PrjApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(Cs1555PrjApp.class, args);
    }
}
